//
//  SEGCustomSecletViewController.m
//  Uhomebk
//
//  Created by liangxinqiang on 15/12/14.
//  Copyright © 2015年 com.segi. All rights reserved.
//

#import "SEGCustomSecletViewController.h"

@implementation SEGCustomSecletViewController

-(void)loadView
{
    CGSize size = [[UIScreen mainScreen] bounds].size;
    UIView *mainView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
    mainView.backgroundColor = kColor_bg;
    self.view = mainView;
    
    self.tableView=[[UITableView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height-kNavigationBarAndStatusBarHeight) style:UITableViewStyleGrouped];
    self.tableView.dataSource=self;
    self.tableView.delegate=self;
    self.tableView.backgroundColor=[UIColor clearColor];
    self.tableView.separatorColor=kColor_L2;
    [self.view addSubview:self.tableView];
    
}
-(void)viewDidLoad
{
    [super viewDidLoad];
    self.title=self.titleName;
    [self showCustomNavigationBackButton];
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.01;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellStr=@"cell";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellStr];
    
    if (cell==nil) {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellStr];
        cell.textLabel.textColor=kColor_1;
        cell.textLabel.font=[UIFont systemFontOfSize:FONT_LIST_AND_DETAIL_SIZE];
        cell.textLabel.text=[[self.dataArray objectAtIndex:indexPath.row] objectForKey:self.textKey];
        if (self.detailTextKey) {
            double detail=[[[self.dataArray objectAtIndex:indexPath.row] objectForKey:self.detailTextKey] doubleValue]/100;
            cell.detailTextLabel.text=[NSString stringWithFormat:@"%.2f元",detail];
        }
        cell.detailTextLabel.textColor=kColor_2;
        cell.detailTextLabel.font=[UIFont systemFontOfSize:FONT_LIST_AND_DETAIL_SIZE];
    }
    
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [self.navigationController popViewControllerAnimated:YES];
    [self.selectDelegate selectedData:[self.dataArray objectAtIndex:indexPath.row]];
    
}

@end
